import React from 'react'
import { connect,useSelector,useDispatch,useBoundDispatch} from '../react-redux'
import actionCreators  from '../store/actionCreators/counter2';

function Counter2(props){
    //状态映射函数 替代connect(mapStateToProps)
    let { number } = useSelector(state=>state.counter2);
    //dispatch映射函数 替代connect(mapDispatchToProps)
    let { add2,minus2 } = useBoundDispatch(actionCreators);
    return (
        <div>
            <p>{number}</p>
            <button onClick={add2}>+</button>
            <button onClick={minus2}>-</button>
        </div>
    )
}

export default Counter2


